#include <stdio.h>

void swap(void *x, void *y, int size)
{

    char *p = x;
    char *q = y;
    while (size--)
    {
        char temp = *p;
        *p = *q;
        *q = temp;
        p++;
        q++;
    }
}
int main()
{
    int a = 10;
    int b = 20;

    unsigned char m = 100;
    unsigned char n = 200;

    double x = 3.14;
    double y = 5.1;

    swap(&a, &b, sizeof(int));
    printf("a = %d, b = %d\n", a, b);

    swap(&m, &n, sizeof(char));
    printf("m = %u, n = %u\n", m, n);

    swap(&x, &y, sizeof(double));
    printf("x = %f, y = %f\n", x, y);

    return 0;
}
